package com.fooddiary.model;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.fooddiary.model.entity.ModelEntity;


/**
 * 
 * @author Created by andrey.kuznetsov <br>
 * @author Last modified by $Author$ <br>
 * @author Last modified on $Date$ at revision $Revision$ <br>
 */
@Entity
@Table(name = "weight")
@AttributeOverrides({
	@AttributeOverride(name="id", column=@Column(name="id")),
	@AttributeOverride(name="enabled", column=@Column(name="enabled"))
})
@AssociationOverrides({
	@AssociationOverride( name="model", joinColumns = @JoinColumn(name="model_id"))
})
public class Weight extends ModelEntity implements Serializable{
	
	private static final long serialVersionUID = 3831777527173613101L;

	@Column(name = "date", unique = true, nullable = false, insertable = true, updatable = true)
	private Long date;
	
	@Column(name = "weight", unique = false, nullable = false, insertable = true, updatable = true)
	private Double weight;

	@Column(name = "trenning", unique = false, nullable = false, insertable = true, updatable = true)
	private Short trenning;
	
	@OneToMany(fetch=FetchType.EAGER, cascade=CascadeType.ALL, mappedBy="weight")
	private Set<Eating> eatings;
	
	/**
	 * Returns date of weigth measurement <br>
	 * @return {@link Long};
	 */
	public Long getDate() {
		return date;
	}

	/**
	 * Sets date of measurement <br>
	 * @param p_date - {@link Long};
	 */
	public void setDate(Long p_date) {
		date = p_date;
	}

	/**
	 * Returns weight <br>
	 * @return {@link Double};
	 */
	public Double getWeight() {
		return weight;
	}

	/**
	 * Sets weight <br>
	 * @param p_weight - {@link Double};
	 */
	public void setWeight(Double p_weight) {
		weight = p_weight;
	}

	/**
	 * Returns trenning flag <br>
	 * @return {@link Short};
	 */
	public Short getTrenning() {
		return trenning;
	}

	/**
	 * Sets trenning flag <br>
	 * @param p_trenning - {@link Short};
	 */
	public void setTrenning(Short p_trenning) {
		trenning = p_trenning;
	}

	/**
	 * Returns eatings set <br>
	 * @return {@link Set<Eating>};
	 */
	public Set<Eating> getEatings() {
		return eatings;
	}

	/**
	 * Sets eatings set <br>
	 * @param p_eatings - {@link Set<Eating>};
	 */
	public void setEatings(Set<Eating> p_eatings) {
		eatings = p_eatings;
	}
	
	
}
